package com.example.eos.mapper;

import com.example.eos.bean.Reply;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReplyMapper {

    //查询回复（回复id）
    @Select("select replyid, commentid, userid, touserid, reply, replytime from reply where replyid = #{replyid,jdbcType=VARCHAR}")
    Reply findByReplyid(String replyid);

    //查询回复（发表id）
    @Select("select replyid, commentid, userid, touserid, reply, replytime from reply where commentid = #{commentid,jdbcType=VARCHAR}")
    List<Reply> findByComment(String commentid);

    //新建回复
    @Insert("insert into reply (replyid, commentid, userid, touserid, reply, replytime) values (#{replyid,jdbcType=VARCHAR}, #{commentid,jdbcType=VARCHAR}, #{userid,jdbcType=VARCHAR}, #{touserid,jdbcType=VARCHAR}, #{reply,jdbcType=VARCHAR}, #{replytime})")
    void save(Reply reply);

    //删除回复
    @Update("update reply set reply = '' where replyid = #{replyid,jdbcType=VARCHAR}")
    void deleteByReplyid(String replyid);

}
